package com.diors.game.example.server;

import com.diors.commons.config.properties.ConfigManager;
import com.diors.commons.config.xmlbean.XmlEngine;
import com.diors.commons.log.DiorsLogger;
import com.diors.game.engine.thread.ThreadPoolManager;
import com.diors.game.example.server.config.NetworkConfig;
import com.diors.game.example.server.xmldata.XmlDataManager;

/**
 * 初始化游戏逻辑信息
 * @author	darren.ouyang
 * @data	2013-9-16
 */
public class GameServerInit 
{

	private DiorsLogger log = DiorsLogger.getLogger(GameServerInit.class);
	
	private final static GameServerInit instance = new GameServerInit();
	
	private GameServerInit(){}
	
	public static GameServerInit getInstrance ()
	{
		return instance;
	}
	
	/**
	 * 初始化游戏服务器方法
	 * @throws Exception
	 * @create	2013-9-16	darren.ouyang
	 */
	public void init () throws Exception
	{
		initConfig();
		initXml();
		initDao();
		initThreadd();
		initSystem();
	}
	
	/**
	 * 初始化配置文件
	 * @throws Exception
	 * @create	2013-9-16	darren.ouyang
	 */
	private void initConfig () throws Exception
	{
		ConfigManager.newInstance().loads(NetworkConfig.class);
		
		log.info("配置文件初始化完毕！！");
	}
	
	/**
	 * 初始化数据库Dao
	 * @throws Exception
	 * @create	2013-9-16	darren.ouyang
	 */
	private void initDao () throws Exception
	{
		log.info("数据库初始化完毕！！");
	}
	
	/**
	 * 初始化Xml
	 * @throws Exception
	 * @create	2013-9-16	darren.ouyang
	 */
	private void initXml () throws Exception
	{
		XmlEngine.load(new XmlDataManager());
		log.info("XML数据初始化完毕！！");
	}
	
	/**
	 * 初始化线程相关
	 * @throws Exception
	 * @create	2013-9-16	darren.ouyang
	 */
	private void initThreadd () throws Exception
	{
		ThreadPoolManager.getInstance();
		log.info("线程相关初始化完毕！！");
	}
	
	/**
	 * 初始化游戏系统相关信息
	 * @throws Exception
	 * @create	2013-9-16	darren.ouyang
	 */
	private void initSystem () throws Exception
	{
		log.info("游戏系统相关初始化完毕！！");
	}
}
